<!--
 * @Description: 过泵管理
 * @Autor: wangwangwang
 * @Date: 2021-01-20 11:54:04
 * @LastEditors: wangwangwang
 * @LastEditTime: 2021-03-29 13:52:11
-->
<template>
  <div class="pages">
    <div class="top">
      <div class="search">
        <div class="search_left">
          <div>
            <span style="margin-right: 15px;">地磅</span>
            <el-select v-model="loadometer" @change="changeLoadometer">
              <el-option label="地磅一" value="com1"></el-option>
              <el-option label="地磅二" value="com2"></el-option>
            </el-select>
          </div>
          <div :style="checked?'margin-left: 24px;display:flex; align-items: center;color:#cccccc':'margin-left: 24px;display:flex; align-items: center;'">
            <span style="margin-right: 5px;">数据：</span>
            <div style="width: 140px;font-size:24px;padding:0 50px 0 0px">{{socketData&&!checked?socketData+'吨':''}}</div>
          </div>
          <div style="margin-left: 24px;">
            <el-checkbox v-model="checked">
              <div style="display:flex; align-items: center;">
                <span style="margin-right: 15px;">录入过磅数据</span>
                <el-input v-model="socketData1" type="Number" style="width: 140px;" :disabled="!checked" @change="netWeightFun(socketData1)">
                  <template slot="append">吨</template>
                </el-input>
              </div>
            </el-checkbox>
          </div>
          <el-button size="medium" class="save_button" @click="saveWeightData">保 存</el-button>
        </div>
        <div class="search_right">
          <el-Badge :value="noticeList.length" class="item">
            <div class="text" @click="noticeVisible=!noticeVisible">
              消息通知
            </div>
          </el-Badge>
          <div v-show="noticeVisible" class="notice-container">
            <el-table :data="noticeList" style="width: 100%">
              <el-table-column prop="title" label="消息标题" width="180">
              </el-table-column>
              <el-table-column prop="time" label="时间" width="180">
              </el-table-column>
              <el-table-column align="center" label="操作" min-width="180">
                <template slot-scope="scope" fixed="right">
                  <el-button class="bottom_one" size="mini" @click="handleDetails(scope.row)">
                    查看
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>
      <div class="bottom">
        <div class="title">过磅类型</div>
        <div class="top_nav">
          <template v-for="(item,index) in typeList">
            <div :key="index" :class="item.value==type?'active':'div'" @click="changeType(item.value)">{{item.name}}</div>
          </template>
        </div>
        <!-- 过磅类型 -->
        <div v-show="type==0" class="top_table">
          <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" :row-style="{height:' 100px'}" border stripe style="width:100%" :data="table1" tooltip-effect="dark">
            <el-table-column align="center" label="检测状态">
              {{['未检测','已检测'][weightData.checkStatus]}}
            </el-table-column>
            <el-table-column align="center" label="车牌号" width="120px">
              <el-input v-model="WeightParams.carNo" oninput="if(value.length>7)value=value.slice(0,8)" placeholder="请输入" style="width:100%" @input="getWeight"></el-input>
            </el-table-column>
            <el-table-column align="center" label="供应商">
              {{weightData.supplier}}
            </el-table-column>
            <el-table-column align="center" label="物料名称" width="120">
              {{weightData.rawName}}
              <!-- <el-select v-model="weightData.rawId" placeholder="请选择">
                <el-option v-for="(item, index) in materialsList" :key="index" :label="item.name" :value="item.id"></el-option>
              </el-select> -->
            </el-table-column>
            <el-table-column align="center" label="规格">
              {{weightData.specification}}
            </el-table-column>
            <el-table-column align="center" label="卸料仓" width="160">
              <el-select v-model="weightData.repertoryId" placeholder="请选择" style="width:100%">
                <el-option v-for="(item, index) in repertoryList" :key="index" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-table-column>
            <el-table-column align="center" label="货票量" width="120px">
              <el-input v-model="weightData.ticketNum" type="Number" placeholder="请输入" style="width:100%"></el-input>
            </el-table-column>
            <el-table-column align="center" label="含水率（%）" width="105px">
              <el-input v-model="weightData.moistureContent" type="Number" oninput="if(value>100)value=100" placeholder="请输入" style="width:100%"></el-input>
            </el-table-column>
            <el-table-column align="center" label="毛重（吨）" width="95px">
              {{weightData.firstWeight}}
            </el-table-column>
            <el-table-column align="center" label="皮重（吨）" width="95px">
              {{weightData.secondWeight}}
            </el-table-column>
            <el-table-column align="center" label="净重（吨）" width="95px">
              <div v-if="weightData.secondWeight!=null">
                {{weightData.netWeight}}
              </div>
            </el-table-column>
            <el-table-column align="center" label="含水扣减量" width="100px">
              {{weightData.deductionWaterNum=Number(weightData.netWeight)*Number(weightData.moistureContent)/100||0}}
            </el-table-column>
            <el-table-column align="center" label="异常扣减量" width="100px">
              <el-input v-model="weightData.deductionExceptionNum" type="Number" placeholder="请输入" style="width:100%" @change="netWeightFun(socketData1)"></el-input>
            </el-table-column>
            <el-table-column align="center" label="收货量（吨）" width="105px">
              <div v-if="weightData.secondWeight!=null">
                {{weightData.receiveNum}}
              </div>
            </el-table-column>
            <el-table-column align="center" label="司机" width="100px">{{weightData.driver}}</el-table-column>
            <el-table-column align="center" label="甲供" width="80px">
              <el-checkbox v-model="weightData.nailProvider" :true-label="1" :false-label="0">是</el-checkbox>
            </el-table-column>
            <el-table-column align="center" label="是否退货" width="80px">
              <el-checkbox v-model="weightData.returnGoods" :true-label="1" :false-label="0">是</el-checkbox>
            </el-table-column>
            <el-table-column align="center" label="供气" width="80px">
              <el-checkbox v-model="weightData.supplyGas" :true-label="1" :false-label="0">是</el-checkbox>
            </el-table-column>
            <el-table-column align="center" label="备注" width="220px">
              <el-input v-model="weightData.remark" placeholder="请输入" style="width:100%"></el-input>
            </el-table-column>
          </el-table>
        </div>
        <!-- 罐车出站 -->
        <div v-show="type==1" class="top_table">
          <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" :row-style="{height:' 100px'}" border stripe style="width:100%" :data="table1" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" width="120px">
              <el-input v-model="WeightParams.carNo" oninput="if(value.length>7)value=value.slice(0,7)" placeholder="请输入" style="width:100%" @input="getWeight"></el-input>
            </el-table-column>
            <el-table-column align="center" label="物流号">
              {{weightData.logisticsCode}}
            </el-table-column>
            <el-table-column align="center" label="工程名称">
              {{weightData.engineeringName}}
            </el-table-column>
            <el-table-column align="center" label="浇筑部位">
              {{weightData.structuralParts}}
            </el-table-column>
            <el-table-column align="center" label="标号">
              {{weightData.gradeNo}}
            </el-table-column>
            <el-table-column align="center" label="票面量 (方)" width="105px">
              {{weightData.faceValue}}
            </el-table-column>
            <el-table-column align="center" label="容重" width="105px">
              {{weightData.unitWeight}}
            </el-table-column>
            <el-table-column align="center" label="出站毛重（吨）" width="105px">
              {{weightData.grossWeight}}
            </el-table-column>
            <el-table-column align="center" label="皮重（吨）" width="105px">
              {{weightData.tareWeight}}
            </el-table-column>
            <el-table-column align="center" label="净重（吨）" width="105px">
              {{weightData.netWeight}}
            </el-table-column>
            <el-table-column align="center" label="方量 (方）" width="105px">
              {{weightData.actualVolume}}
            </el-table-column>
            <el-table-column align="center" label="误差量（方）" width="105px">
              {{weightData.residueNum}}
            </el-table-column>
          </el-table>
        </div>
        <!-- 罐车回站 -->
        <div v-show="type==2" class="top_table">
          <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" :row-style="{height:' 100px'}" border stripe style="width:100%" :data="table1" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" width="120px">
              <el-input v-model="WeightParams.carNo" oninput="if(value.length>7)value=value.slice(0,7)" placeholder="请输入" style="width:100%" @input="getWeight"></el-input>
            </el-table-column>
            <el-table-column align="center" label="物流号">
              {{weightData.logisticsCode}}
            </el-table-column>
            <el-table-column align="center" label="工程名称">
              {{weightData.engineeringName}}
            </el-table-column>
            <el-table-column align="center" label="浇筑部位">
              {{weightData.structuralParts}}
            </el-table-column>
            <el-table-column align="center" label="标号">
              {{weightData.gradeNo}}
            </el-table-column>
            <el-table-column align="center" label="票面量 (方)" width="105px">
              {{weightData.faceValue}}
            </el-table-column>
            <el-table-column align="center" label="容重" width="105px">
              {{weightData.unitWeight}}
            </el-table-column>
            <el-table-column align="center" label="回站毛重（吨）" width="105px">
              {{weightData.grossWeight}}
            </el-table-column>
            <el-table-column align="center" label="皮重（吨）" width="105px">
              {{weightData.tareWeight}}
            </el-table-column>
            <el-table-column align="center" label="净重（吨）" width="105px">
              {{weightData.netWeight}}
            </el-table-column>
            <el-table-column align="center" label="方量 (方）" width="105px">
              {{weightData.actualVolume}}
            </el-table-column>
            <el-table-column align="center" label="余料量（方）" width="105px">
              {{weightData.residueNum}}
            </el-table-column>
            <el-table-column align="center" label="误差量（方）" width="105px">
              {{weightData.residueNum}}
            </el-table-column>
            <el-table-column align="center" label="使用量（方）" width="105px">
              {{weightData.useNum}}
            </el-table-column>
          </el-table>
        </div>
        <!-- 罐车皮重 -->
        <div v-show="type==3" class="top_table">
          <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" :row-style="{height:' 100px'}" border stripe style="width:100%" :data="table1" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" width="120px">
              <el-input v-model="WeightParams.carNo" oninput="if(value.length>7)value=value.slice(0,7)" placeholder="请输入" style="width:100%" @input="getWeight"></el-input>
            </el-table-column>
            <el-table-column align="center" label="所属单位">
              {{weightData.company}}
            </el-table-column>
            <el-table-column align="center" label="载重方量">
              {{weightData.maxLoad}}
            </el-table-column>
            <el-table-column align="center" label="历史皮重">
              {{weightData.prefixTareWeight}}
            </el-table-column>
            <el-table-column align="center" label="本次皮重">
              {{weightData.currentTareWeight}}
            </el-table-column>
            <el-table-column align="center" label="过磅时间">
              {{weightData.weightTime}}
            </el-table-column>
          </el-table>
        </div>
        <!-- 特材入库 -->
        <div v-show="type==4" class="top_table">
          <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" :row-style="{height:' 100px'}" border stripe style="width:100%" :data="table1" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" width="120px">
              <el-input v-model="WeightParams.carNo" oninput="if(value.length>7)value=value.slice(0,7)" placeholder="请输入" style="width:100%" @input="getWeight"></el-input>
            </el-table-column>
            <el-table-column align="center" label="成品名称">
              <el-select ref="productId" v-model="weightData.productId" placeholder="请选择" @change="weightData.productType=productList.find(res=>(res.id==weightData.productId)).type,$nextTick(()=>{weightData.productName = $refs.productId.selectedLabel})">
                <el-option v-for="(item, index) in productList" :key="index" :label="item.productName" :value="item.id"></el-option>
              </el-select>
            </el-table-column>
            <el-table-column align="center" label="成品型号">
              {{weightData.productType}}
            </el-table-column>
            <el-table-column align="center" label="液位仪">
              <el-select ref="meterId" v-model="weightData.meterId" placeholder="请选择" @change="$nextTick(()=>{weightData.meterName = $refs.meterId.selectedLabel})">
                <el-option v-for="(item, index) in meterList" :key="index" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-table-column>
            <el-table-column align="center" label="出货量">
              {{weightData.shipment}}
            </el-table-column>
            <el-table-column align="center" label="毛重">
              {{weightData.firstWeight}}
            </el-table-column>
            <el-table-column align="center" label="皮重">
              {{weightData.secondWeight}}
            </el-table-column>
            <el-table-column align="center" label="净重">
              {{weightData.netWeight}}
            </el-table-column>
            <el-table-column align="center" label="收货量">
              <el-input v-model="weightData.receiveNum" style="width:100%" type="Number"></el-input>
            </el-table-column>
            <el-table-column align="center" label="司机">
              {{weightData.driver}}
            </el-table-column>
            <el-table-column align="center" label="备注">
              <el-input v-model="WeightParams.remark" style="width:100%"></el-input>
            </el-table-column>
          </el-table>
        </div>
        <!-- 特材返料 -->
        <div v-show="type==5" class="top_table">
          <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" :row-style="{height:' 100px'}" border stripe style="width:100%" :data="table1" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" width="120px">
              <el-input v-model="WeightParams.carNo" oninput="if(value.length>7)value=value.slice(0,7)" placeholder="请输入" style="width:100%" @input="getWeight"></el-input>
            </el-table-column>
            <el-table-column align="center" label="成品名称">
              {{weightData.productName}}
            </el-table-column>
            <el-table-column align="center" label="成品型号">
              {{weightData.productType}}
            </el-table-column>
            <el-table-column align="center" label="液位仪">
              <el-select ref="meterId" v-model="weightData.meterId" placeholder="请选择" @change="$nextTick(()=>{weightData.meterName = $refs.meterId.selectedLabel})">
                <el-option v-for="(item, index) in meterList" :key="index" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </el-table-column>
            <el-table-column align="center" label="返料量">
              {{weightData.shipment}}
            </el-table-column>
            <el-table-column align="center" label="皮重">
              {{weightData.firstWeight}}
            </el-table-column>
            <el-table-column align="center" label="毛重">
              {{weightData.secondWeight}}
            </el-table-column>
            <el-table-column align="center" label="净重">
              {{weightData.netWeight}}
            </el-table-column>
            <el-table-column align="center" label="司机">
              {{weightData.driver}}
            </el-table-column>
            <el-table-column align="center" label="备注">
              <el-input v-model="WeightParams.remark" style="width:100%"></el-input>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
    <div class="center">
      <!-- 站内车辆 -->
      <div class="left">
        <div class="title">站内车辆</div>
        <div class="table">
          <el-table v-show="type<4" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" border style="width:100%" height="450px" :data="table2" tooltip-effect="dark" :row-class-name="tableRowClassName" @row-click="rowClick">
            <el-table-column align="center" label="制卡/销卡">
              <template slot-scope="scope">
                <!-- {{ scope.row.printCard==1?'制卡':scope.row.printCard==2?'销卡':'未制卡'}} -->
                <el-button :key="scope.row.id" disabled size="medium" class="bottom_all_two" style="margin-left: 12px">制卡</el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" label="车牌号" prop="deliveryVehicl"></el-table-column>
            <el-table-column align="center" label="物料名称" prop="rawName"></el-table-column>
            <el-table-column align="center" label="规格" prop="specification"></el-table-column>
            <el-table-column align="center" label="货票量" prop="ticketNum"> </el-table-column>
            <el-table-column align="center" label="毛重" prop="firstWeight"> </el-table-column>
            <el-table-column align="center" label="卸料仓" width="160" prop="repertoryId">
              <template slot-scope="scope">
                <el-select v-model="scope.row.repertoryId" placeholder="请选择" style="width:100%" @change="changeRepertory(scope.row, scope.row.repertoryId)">
                  <el-option v-for="(item, index) in repertoryList" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column align="center" label="入场时间" prop="firstTime"></el-table-column>
          </el-table>
          <el-table v-show="type>3" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" border stripe style="width:100%" height="450px" :data="table2" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" prop="carNo"></el-table-column>
            <el-table-column align="center" label="特材成品名称" prop="productName"></el-table-column>
            <el-table-column align="center" label="成品型号" prop="productType"></el-table-column>
            <el-table-column align="center" label="毛重" prop="firstWeight"> </el-table-column>
            <el-table-column align="center" label="入厂时间" prop="firstTime"></el-table-column>
          </el-table>
        </div>
      </div>
      <div class="hr"></div>
      <!-- 过磅记录 -->
      <div class="right">
        <div class="title">过磅记录</div>
        <div class="table">
          <el-row>
            <el-col :span="8">
              <div class="input">
                <span class="text">过磅类型</span>
                <el-select v-model="type" disabled placeholder="请选择">
                  <el-option v-for="(item, index) in typeList" :key="index" :label="item.name" :value="item.value"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col v-if="type!=3" :span="12">
              <div style="padding-right:24px">
                <el-date-picker v-model="DatePicker" unlink-panels style="width:100%;height:36px" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" start-placeholder="开始日期" end-placeholder="结束日期">
                </el-date-picker>
              </div>
            </el-col>
            <el-col :span="4">
              <div style="padding-right:24px">
                <el-button icon="el-icon-search" size="medium" class="save_button" @click="gettable3">查询</el-button>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="input">
                <span class="text">车牌号</span>
                <el-input v-model="table3formData.deliveryVehicl" placeholder="请输入" clearable />
              </div>
            </el-col>
            <el-col v-if="type==0" :span="8">
              <div class="input">
                <span class="text">供应商</span>
                <el-input v-model="table3formData.supplier" placeholder="请输入" clearable />
              </div>
            </el-col>
            <el-col v-if="type==0" :span="8">
              <div class="input">
                <span class="text">物料</span>
                <el-select v-model="table3formData.rawId" placeholder="请选择">
                  <el-option v-for="(item, index) in materialsList" :key="index" :label="item.name" :value="item.rawId"></el-option>
                </el-select>
              </div>
            </el-col>
            <el-col v-if="type>3" :span="8">
              <div class="input">
                <span class="text">司机名称</span>
                <el-input v-model="table3formData.driver" placeholder="请输入" clearable />
              </div>
            </el-col>
            <el-col v-if="type>3" :span="8">
              <div class="input">
                <span class="text">产品名称</span>
                <el-input v-model="table3formData.productName" placeholder="请输入" clearable />
              </div>
            </el-col>
          </el-row>
          <!-- 原物料过磅 -->
          <el-table v-if="type==0" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" border stripe style="width:100%" height="346" :data="table3" tooltip-effect="dark">
            <el-table-column align="center" label="检测状态">
              <template slot-scope="scope">
                {{['未检测','已检测'][scope.row.checkStatus]}}
              </template>
            </el-table-column>
            <el-table-column align="center" label="车牌号" prop="deliveryVehicl"></el-table-column>
            <el-table-column align="center" label="供应商" prop="supplier"></el-table-column>
            <el-table-column align="center" label="物料名称" prop="rawName"></el-table-column>
            <el-table-column align="center" label="规格" prop="specification"></el-table-column>
            <el-table-column align="center" label="卸料仓" prop="repertory"></el-table-column>
            <el-table-column align="center" label="货票量" prop="ticketNum"> </el-table-column>
            <el-table-column align="center" label="含水率" prop="moistureContent"></el-table-column>
            <el-table-column align="center" label="毛重" prop="firstWeight"></el-table-column>
            <el-table-column align="center" label="皮重" prop="secondWeight"></el-table-column>
            <el-table-column align="center" label="净重" prop="netWeight"></el-table-column>
            <el-table-column align="center" label="含水扣减量" prop="deductionWaterNum"></el-table-column>
            <el-table-column align="center" label="异常扣减量" prop="deductionExceptionNum"></el-table-column>
            <el-table-column align="center" label="收货量" prop="receiveNum"></el-table-column>
            <el-table-column align="center" label="司机" prop="driver"></el-table-column>
            <el-table-column align="center" label="甲供">
              <template slot-scope="scope">
                {{scope.row.nailProvider==0?'否':'是'}}
              </template>
            </el-table-column>
            <el-table-column align="center" label="是否退货">
              <template slot-scope="scope">
                {{scope.row.returnGoods==0?'否':'是'}}
              </template>
            </el-table-column>
            <el-table-column align="center" label="备注" prop="remark"></el-table-column>
            <el-table-column align="center" label="入场时间" prop="firstTime"></el-table-column>
            <el-table-column align="center" label="出场时间" prop="secondTime"></el-table-column>
            <el-table-column align="center" fixed="right" label="操作">
              <template slot-scope="scope">
                <span class="table_link" @click="open('dialog',scope.row)">详情</span>
              </template>
            </el-table-column>
          </el-table>
          <!-- 罐车出站 -->
          <el-table v-if="type==1" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" border stripe style="width:100%" height="346" :data="table3" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" prop="carNo"></el-table-column>
            <el-table-column align="center" label="物流号" prop="logisticsCode"></el-table-column>
            <el-table-column align="center" label="工程名称" prop="engineeringName"></el-table-column>
            <el-table-column align="center" label="浇筑部位" prop="structuralParts"></el-table-column>
            <el-table-column align="center" label="标号" prop="gradeNo"></el-table-column>
            <el-table-column align="center" label="票面量 (方)" prop="faceValue"> </el-table-column>
            <el-table-column align="center" label="容重" prop="unitWeight"></el-table-column>
            <el-table-column align="center" label="出站毛重（吨）" prop="grossWeight"></el-table-column>
            <el-table-column align="center" label="出站皮重（吨）" prop="tareWeight"></el-table-column>
            <el-table-column align="center" label="净重（吨）" prop="netWeight"></el-table-column>
            <el-table-column align="center" label="方量 (方）" prop="actualVolume"></el-table-column>
            <el-table-column align="center" label="误差量（方）" prop="residueNum"></el-table-column>
            <el-table-column align="center" label="过磅时间" prop="weightTime"></el-table-column>
          </el-table>
          <!-- 罐车回站 -->
          <el-table v-if="type==2" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" border stripe style="width:100%" height="346" :data="table3" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" prop="carNo"></el-table-column>
            <el-table-column align="center" label="物流号" prop="logisticsCode"></el-table-column>
            <el-table-column align="center" label="工程名称" prop="engineeringName"></el-table-column>
            <el-table-column align="center" label="浇筑部位" prop="structuralParts"></el-table-column>
            <el-table-column align="center" label="标号" prop="gradeNo"></el-table-column>
            <el-table-column align="center" label="票面量（方）" prop="faceValue"> </el-table-column>
            <el-table-column align="center" label="容重" prop="unitWeight"></el-table-column>
            <el-table-column align="center" label="回站毛重（吨）" prop="grossWeight"></el-table-column>
            <el-table-column align="center" label="皮重（吨）" prop="tareWeight"></el-table-column>
            <el-table-column align="center" label="方量 (方）" prop="actualVolume"></el-table-column>
            <el-table-column align="center" label="余料量（方）" prop="residueNum"></el-table-column>
            <el-table-column align="center" label="使用量（方）" prop="useNum"></el-table-column>
            <el-table-column align="center" label="过磅时间" prop="weightTime"></el-table-column>
          </el-table>
          <!-- 罐车皮重 -->
          <el-table v-show="type==3" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ border: 'none' }" border stripe style="width:100%" height="346" :data="table3" tooltip-effect="dark">
            <el-table-column align="center" label="车牌号" prop="carNo">
              <template slot-scope="item">
                {{item.row.carNo}}
              </template>
            </el-table-column>
            <el-table-column align="center" label="所属单位" prop="company"></el-table-column>
            <el-table-column align="center" label="载重方量" prop="maxLoad"></el-table-column>
            <el-table-column align="center" label="历史皮重" prop="prefixTareWeight"></el-table-column>
            <el-table-column align="center" label="本次皮重" prop="currentTareWeight"></el-table-column>
            <el-table-column align="center" label="过磅时间" prop="weightTime"></el-table-column>
          </el-table>
          <!-- 特材入库，特材返料 -->
          <el-table v-show="type==4||type==5" ref="table4-5" :header-cell-style="{ background: ' #f3f6f9' }" :cell-style="{ border: 'none' }" border stripe style="width:100%" height="346" :data="table3" tooltip-effect="dark">
            <el-table-column align="center" label="运输号" prop="code"></el-table-column>
            <el-table-column align="center" label="车牌号" prop="carNo"></el-table-column>
            <el-table-column v-if="type==5" :key="50" align="center" label="液位仪" prop="meterName"></el-table-column>
            <el-table-column align="center" label="特材成品名称" prop="productName"></el-table-column>
            <el-table-column align="center" label="成品型号" prop="productType"></el-table-column>
            <el-table-column align="center" label="第一次过磅量" prop="firstWeight"></el-table-column>
            <el-table-column align="center" label="第一次过磅时间" prop="firstTime"></el-table-column>
            <el-table-column align="center" label="第二次过磅量" prop="secondWeight"></el-table-column>
            <el-table-column align="center" label="第二次过磅时间" prop="secondTime"></el-table-column>
            <el-table-column v-if="type==5" :key="51" align="center" label="返料量" prop="shipment"></el-table-column>
            <el-table-column v-if="type==4" :key="52" align="center" label="收货量" prop="receiveNum"></el-table-column>
            <el-table-column v-if="type==4" :key="53" align="center" label="出货量" prop="shipment"></el-table-column>
            <el-table-column align="center" label="入库量" prop="netWeight"></el-table-column>
            <el-table-column align="center" label="司机" prop="driver"></el-table-column>
          </el-table>
        </div>
      </div>
    </div>
    <div class="echarts">
      <div class="left">
        <div class="left_nav">
          <div>
            <span style="margin-right: 15px;">原物料</span>
            <el-select v-model="charts1Data.rawId" style="width:160px" placeholder="请选择">
              <el-option v-for="(item,index) in rawIdList" :key="index" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </div>
          <div>
            <span style="margin:0 15px 0 25px;">日期</span>
            <el-date-picker v-model="charts1Data.needDate" type="datetime" style="width:200px" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss"> </el-date-picker>
          </div>
          <el-button style="margin-left: 15px;" size="medium" class="save_button" @click="getecharts1">统 计</el-button>
        </div>
        <div id="echarts1"></div>
      </div>
      <div class="hr"></div>
      <div class="right">
        <div id="echarts2"></div>
      </div>
    </div>
    <!-- 原物料详情 -->
    <el-dialog :visible.sync="dialog" width="880px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">查看详情</span>
      <div class="dialoginfo">
        <el-form :inline=" true" label-width="110px">
          <div>
            <el-form-item>
              <span slot="label">车牌号：</span>
              <div class="text1" style="width:280px;">{{low.deliveryVehicl}}</div>
            </el-form-item>
            <el-form-item>
              <span slot="label">供应商：</span>
              <div class="text1" style="width:280px;">{{low.supplier}}</div>
            </el-form-item>
            <el-form-item>
              <span slot="label">状态：</span>
              <div class="text1" style="width:280px;">
                {{low.receiveStatus==1?'运输中':low.receiveStatus==2?'检验中':low.receiveStatus==3?'卸料中':low.receiveStatus==4?'内部确认中':low.receiveStatus==5?'外部确认中':low.receiveStatus==6?'已接受':'退回'}}
              </div>
            </el-form-item>
          </div>
          <div>
            <el-form-item>
              <span slot="label">材料名称：</span>
              <div class="text1" style="width:280px">{{low.rawName}}</div>
            </el-form-item>
            <el-form-item>
              <span slot="label">材料规格：</span>
              <div class="text1" style="width:280px">{{low.specification}}</div>
            </el-form-item>
          </div>
          <el-form-item>
            <span slot="label">入场时间：</span>
            <div class="text1" style="width:280px">{{low.firstTime||''}}</div>
          </el-form-item>
          <el-form-item>
            <span slot="label">出场时间：</span>
            <div class="text1" style="width:280px">{{low.secondTime||''}}</div>
          </el-form-item>
          <div class="col">
            <div>
              <el-form-item>
                <span slot="label" style="line-height:133px;">收货量：</span>
                <div class="text1" style="width:120px;height:133px;">{{low.receiveNum||0}}</div>
              </el-form-item>
            </div>
            <div>
              <div>
                <el-form-item>
                  <span slot="label">毛重：</span>
                  <div class="text1" style="width:160px">{{low.firstWeight||0}}</div>
                </el-form-item>
                <el-form-item>
                  <span slot="label">含水率：</span>
                  <div class="text1" style="width:160px">{{low.moistureContent||0}}</div>
                </el-form-item>
              </div>
              <div>
                <el-form-item>
                  <span slot="label">皮重：</span>
                  <div class="text1" style="width:160px">{{low.secondWeight||0}}</div>
                </el-form-item>
                <el-form-item>
                  <span slot="label">含水扣减量：</span>
                  <div class="text1" style="width:160px">{{low.deductionWaterNum||0}}</div>
                </el-form-item>
              </div>
              <div>
                <el-form-item>
                  <span slot="label">净重：</span>
                  <div class="text1" style="width:160px">{{low.netWeight||0}}</div>
                </el-form-item>
                <el-form-item>
                  <span slot="label">异常扣减量：</span>
                  <div class="text1" style="width:160px">{{low.deductionExceptionNum||0}}</div>
                </el-form-item>
              </div>
            </div>
          </div>
          <el-form-item>
            <span slot="label">备注</span>
            <div class="text1" style="width:550px">{{low.remark||''}}</div>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <span>
          <el-button class="bottom_all" @click="print()">打 印</el-button>
        </span>
        <span>
          <el-button class="bottom_all" style="margin-left:24px" @click="rawSupplierSendMessageFun(low)">发 送</el-button>
        </span>
        <span>
          <el-button class="bottom_all_two" style="margin-left:24px" @click="dialog=false">关 闭</el-button>
        </span>
      </span>
    </el-dialog>
    <!-- 打印区域 -->
    <div class="print" style="background: #fff;width: 100%; width:1075px;display:none">
      <h1 style="text-align: center;width: 100%;">{{low.supplier}}</h1>
      <div style="display:flex;width: 100%;justify-content: space-between;">
        <div> 物料：{{low.rawName+low.specification}}</div>
        <div> 车牌号：{{low.deliveryVehicl}}</div>
        <div> 时间：{{low.firstTime||''+'-'+low.secondTime||''}}</div>
      </div>
      <div style="wodth:100%;padding:20px 0">
        <table class="table" style="width:100%; border-collapse: collapse; text-align: center;">
          <tr>
            <td style="border: 1px solid #808080;line-height:50px;padding:0 10px;width:33%" rowspan="3">收货量：{{low.receiveNum||0}}</td>
            <td style="border: 1px solid #808080;line-height:50px;padding:0 10px;width:33%">毛重：{{low.firstWeight||0}}</td>
            <td style="border: 1px solid #808080;line-height:50px;padding:0 10px;width:33%">含水率：{{low.moistureContent||0}}</td>
          </tr>
          <tr>
            <td style="border: 1px solid #808080;line-height:50px;padding:0 10px;width:33%">皮重：{{low.secondWeight||0}}</td>
            <td style="border: 1px solid #808080;line-height:50px;padding:0 10px;width:33%">含水扣减量：{{low.deductionWaterNum||0}}</td>
          </tr>
          <tr>
            <td style="border: 1px solid #808080;line-height:50px;padding:0 10px;width:33%">净重：{{low.netWeight||0}}</td>
            <td style="border: 1px solid #808080;line-height:50px;padding:0 10px;width:33%">异常扣减量：{{low.deductionExceptionNum||0}}</td>
          </tr>
          <tr>
            <td style="border: 1px solid #808080;line-height:50px;text-align:left;padding:0 10px" colspan="3">备注：{{low.remark}}</td>
          </tr>
        </table>

      </div>
    </div>
    <!-- 消息详情 -->
    <el-dialog title="查看详情" :visible.sync="dialogMessageVisible">
      <el-table :data="messagelist">
        <el-table-column property="deliveryVehicl" label="车牌号"></el-table-column>
        <el-table-column property="logisticsCode" label="物流号"></el-table-column>
        <el-table-column property="engineeringName" label="工程名称"></el-table-column>
        <el-table-column property="structuralParts" label="浇筑部位"></el-table-column>
        <el-table-column property="gradeNo" label="标号"></el-table-column>
        <el-table-column property="address" label="票面量（方）">
          <template slot-scope="scope">
            <span>{{scope.row.datatype*1===1?scope.row.ticketNum:scope.row.faceValue}}</span>
          </template>
        </el-table-column>
        <el-table-column property="unitWeight" label="容重（密度）"></el-table-column>
        <el-table-column property="grossWeight" label="出站毛重（吨）"></el-table-column>
        <el-table-column property="tareWeight" label="皮重（吨）"></el-table-column>
        <el-table-column property="netWeight" label="净重（吨）"></el-table-column>
        <el-table-column property="actualVolume" label="方量（方）"></el-table-column>
        <el-table-column property="residueNum" label="误差量（方）"></el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>
<script>
import { get_weight_consignment, query_inner_car, get_materials_list, save_or_update_consignment, query_all_car, save_or_update_car, save_or_update_tare, query_weight_tare, query_weight_car, get_weight_tare, get_list, get_tank_car, update_after_weighing, raw_inventory_statistics, rawStatistics, QueryList, getSpecialMaterialsInnerByNo, getSpecialMaterialsRevertByNo, get_special_product_list, get_meter_list, saveOrUpdateSpecialMaterInner, saveOrUpdateSpecialMaterRevert, rawSupplierSendMessage, querySpecialMaterialsInner, queryInstationSpecialMaterial } from './pages'
import { _debounce } from './untils'
import {
  getUserInfo
} from '@/utils/auth';
import { getMessageList, setReadType } from '@/api/common';
import { setTimeout, setInterval } from 'timers';
// var socket;
var echarts = require('echarts');
export default {
  data() {
    return {
      checked: false,
      socketData: '',
      currentIndex: '',
      loadometer: 'com1',
      socketData1: '',
      /**是否第一次过磅*/
      first: true,
      noticeVisible: false,
      dialogMessageVisible: false,
      table1: [{
      }],
      type: 0,
      typeList: [
        { name: '原物料过磅', value: 0 },
        { name: '罐车出站', value: 1 },
        { name: '罐车回站', value: 2 },
        { name: '罐车皮重', value: 3 },
        { name: '特材入库', value: 4 },
        { name: '特材返料', value: 5 },
      ],
      /**原物料*/
      materialsList: [],
      /**仓库*/
      repertoryList: [],
      /**站内车辆*/
      table2: [],
      /**原物料过磅详情*/
      dialog: false,
      low: {
        supplier: '',
        receiveStatus: 0,
        rawName: '',
        specification: '',
        firstTime: '',
        secondTime: '',
        receiveNum: '',
        firstWeight: '',
        moistureContent: '',
        secondWeight: '',
        deductionWaterNum: '',
        netWeight: null,
        deductionExceptionNum: '',
        remark: '',
        code: '',
      },
      /**站点*/
      /**过磅类型*/
      table3formData: {
        deliveryVehicl: '',
        supplier: '',
        rawId: '',
        page: 1,
        pageSize: 99999,
        receiveStationId: ''
      },
      DatePicker: [],
      table3: [],
      WeightParams: {
        receiveStationId: '',
        carNo: '',
        type: 'type_inner'
      },
      /**车辆数据*/
      weightData: {
        netWeight: null
      },
      /**统计图*/
      charts1Data: {
        rawId: "",
        needDate: new Date().Format('yyyy-MM-dd hh:mm:ss'),
      },
      rawIdList: [],
      /**成品名称*/
      productList: [],
      /**成品型号*/
      meterList: [],
      count: 0,//重连，
      dataNumber: 0,//60秒没有数据就必须重连，
      time: null,
      setTime: null,
      isSecond: false,
      noticeList: [],
      messagelist: [],
    };
  },
  async created() {
    this.table3formData.receiveStationId = await getUserInfo().pointIds[0];
    this.WeightParams.receiveStationId = await getUserInfo().pointIds[0];
    console.log(this.WeightParams.receiveStationId);
    this.initWebSocket()
    // setInterval(() => {
    //   this.dataNumber++
    //   if (this.dataNumber == 20) {
    //     this.dataNumber = 0
    //     this.initWebSocket()
    //   }
    // }, 1000)
  },
  async mounted() {
    this.table3formData.receiveStationId = await getUserInfo().pointIds[0];
    this.WeightParams.receiveStationId = await getUserInfo().pointIds[0];
    this.init()
    this.getWeight()
    this.gettable2()
    this.gettable3()
    this.getrawIdList()
    this.getecharts2()
    this.initMessageData();
  },
  watch: {
    DatePicker() {
      console.log(this.DatePicker)
      if (this.DatePicker) {
        if (this.type > 3) {
          this.table3formData.secondTime = this.DatePicker[0]
          this.table3formData.secondTimeEnd = this.DatePicker[1]
        } else {
          this.table3formData.firstTime = this.DatePicker[0]
          this.table3formData.secondTime = this.DatePicker[1]
        }
      } else {
        this.table3formData.firstTime = ''
        this.table3formData.secondTime = ''
      }
    },
  },
  methods: {
    rowClick (row) {
      const currentIndex = this.table2.findIndex(item => item.id === row.id);
      this.currentIndex = currentIndex;
      this.weightData = row;
      this.WeightParams.carNo = row.deliveryVehicl;
    },
    tableRowClassName({rowIndex}) {
      if (rowIndex === this.currentIndex) {
        return 'success-row';
      }
      return '';
    },
    /**
     * @Description: 切换卸料仓
     * @param {*}
     * @Author: wangwangwang
     */
    changeRepertory (data, value) {
      const repertory = this.repertoryList.find(item => item.id === value).name
      const params = {
        id: data.id,
        code: data.code,
        repertoryId: value,
        repertory,
        updateWarehouse:1
      }
      save_or_update_consignment(params).then(res => {
        if (res.code === 1001) {
          this.$message.success('修改成功');
        }
      })
    },
    /**切换分类*/
    async changeType(a) {
      this.type = a
      this.weightData = {}
      this.socketData = ''
      this.socketData1 = ''
      this.WeightParams.carNo = ''
      this.table3formData = this.$options.data().table3formData
      if (this.type == 0) {
        this.init()
      }
      if (this.type == 1) {
        this.WeightParams.type = 'type_outer'
      }
      if (this.type == 2) {
        this.WeightParams.type = 'type_inner'
      }
      if (this.type == 4 || this.type == 5) {
        const { data: meterList } = await get_meter_list({ stationId: this.WeightParams.receiveStationId })
        this.meterList = meterList
        const { data: productList } = await get_special_product_list({ stationId: this.WeightParams.receiveStationId })
        this.productList = productList

      }
      this.gettable2()
      this.gettable3()
    },
    netWeightFun(e) {
      if (this.weightData.secondWeight != null) {
        this.weightData.secondWeight = e
        this.weightData.netWeight = this.weightData.firstWeight - Number(e)
        if (this.weightData.firstWeight != null && this.weightData.typeId == '5661d667be3a44e7815efd25a62d6605') {
          //         [伏阆烜：钉钉-ICPS项目组：3月4号10点19分发
          // 1、对于胶凝材料
          // 0到千分之三（含），则收货量=货票量-各种扣减量；
          // 大于千分之三（不含），小于千分之六（含），则收货量=净重-各种扣减量；
          // 大于千分之六（不含），则点击保存时候给超出千分之六的提示，不能保存数据。
          // 最终算收货量，不管是什么规则都是净重=|毛重-皮重|
          // 2、对于非胶凝材料
          // 收货量=净重-各种扣减量
          //         ]
          let size = (this.weightData.ticketNum - Math.abs(this.weightData.firstWeight - this.socketData1)) / this.weightData.ticketNum
          if (size <= 0.003) {
            this.weightData.receiveNum = this.weightData.ticketNum - this.weightData.deductionWaterNum - this.weightData.deductionExceptionNum
            console.log(this.weightData.receiveNum);
          }
          if (size > 0.003 && size <= 0.006) {
            this.weightData.receiveNum = this.weightData.netWeight - this.weightData.deductionWaterNum - this.weightData.deductionExceptionNum
            console.log(this.weightData.receiveNum);
          }
          if (size > 0.006) {
            this.weightData.receiveNum = ''
            this.$message({
              message: '过磅误差超过6‰',
              type: 'warning'
            });
            return
          }
        } else if (this.weightData.firstWeight != null) {
          this.weightData.receiveNum = this.weightData.netWeight - this.weightData.deductionWaterNum - this.weightData.deductionExceptionNum
        }
      }
    },
    /**保存*/
    async saveWeightData() {
      let _this = this
      if (!_this.weightData.deliveryVehicl && !_this.weightData.carNo) {
        _this.$message.warning('请输入车牌号！！！')
        return
      }
      if (_this.checked && !_this.socketData1) {
        _this.$message.warning('请手动录入数据！！！')
        return
      }
      //非录入时原物料为胶凝材料的typeId=5661d667be3a44e7815efd25a62d6605判断过磅误差超过6‰
      //是手动录入和有了毛重（已经过磅了一次）
      // console.log(_this.checked, _this.weightData.firstWeight, _this.weightData.typeId == '5661d667be3a44e7815efd25a62d6605');
      if (_this.checked && _this.weightData.firstWeight && _this.weightData.typeId == '5661d667be3a44e7815efd25a62d6605') {
        //         [伏阆烜：钉钉-ICPS项目组：3月4号10点19分发
        // 1、对于胶凝材料
        // 0到千分之三（含），则收货量=货票量-各种扣减量；
        // 大于千分之三（不含），小于千分之六（含），则收货量=净重-各种扣减量；
        // 大于千分之六（不含），则点击保存时候给超出千分之六的提示，不能保存数据。
        // 最终算收货量，不管是什么规则都是净重=|毛重-皮重|
        // 2、对于非胶凝材料
        // 收货量=净重-各种扣减量
        //         ]
        let size = (_this.weightData.ticketNum - Math.abs(_this.weightData.firstWeight - _this.socketData1)) / _this.weightData.ticketNum
        if (size > 0.006) {
          this.$message({
            message: '过磅误差超过6‰',
            type: 'warning'
          });
          return
        }
      }
      if (_this.weightData.repertoryId) {
        _this.weightData.repertory = _this.repertoryList.find(item => item.id === _this.weightData.repertoryId).name
      }
      let weight = _this.checked ? _this.socketData1 : _this.socketData
      if (_this.type == 0 || _this.type == 4 || _this.type == 5) {
        if (_this.first) {
          _this.weightData.firstWeight = weight
        } else {
          _this.weightData.secondWeight = weight
        }
      }
      if (_this.type == 1) {
        _this.weightData.grossWeight = weight

      }
      if (_this.type == 2) {
        _this.weightData.grossWeight = weight

      }
      if (_this.type == 3) {
        _this.weightData.currentTareWeight = weight
      }
      if (_this.type == 0) {
        save_or_update_consignment(_this.weightData).then((res) => {
          if (res.code == 1001) {
            _this.$message({
              message: '保存成功！！！',
              type: 'success'
            });
            _this.gettable2()
            _this.gettable3() // 过磅记录
            _this.getWeight()
          }
        })
      }
      if (_this.type == 1) {
        save_or_update_car(_this.weightData).then((res) => {
          if (res.code == 1001) {
            _this.$message({
              message: '保存成功！！！',
              type: 'success'
            });
            _this.gettable2()
            _this.gettable3()
            _this.getWeight()
          }
        })
      }
      if (_this.type == 2) {
        await save_or_update_car(_this.weightData).then(() => {
        })
        await update_after_weighing({ code: _this.weightData.logisticsCode, residueNum: _this.weightData.grossWeight }).then(() => {
        })
        _this.gettable2()
        _this.gettable3()
        _this.getWeight()
      }
      if (_this.type == 3) {
        save_or_update_tare(_this.weightData).then((res) => {
          if (res.code == 1001) {
            _this.$message({
              message: '保存成功！！！',
              type: 'success'
            });
            _this.gettable2()
            _this.gettable3()
            _this.getWeight()
          }
        })
      }
      if (_this.type == 4) {
        saveOrUpdateSpecialMaterInner(_this.weightData).then((res) => {
          if (res.code == 1001) {
            _this.$message({
              message: '保存成功！！！',
              type: 'success'
            });
            _this.gettable2()
            _this.gettable3()
            _this.getWeight()
          }
        })
      }
      if (_this.type == 5) {
        if (!_this.weightData.meterId) {
          this.$message.warning('请选择液位仪')
          return
        }
        saveOrUpdateSpecialMaterRevert(_this.weightData).then((res) => {
          if (res.code == 1001) {
            _this.$message({
              message: '保存成功！！！',
              type: 'success'
            });
            _this.gettable2()
            _this.gettable3()
            _this.getWeight()
          }
        })
      }
      _this.weightData = {}
      _this.socketData = ''
      _this.socketData1 = ''
      _this.WeightParams.carNo = ''
      _this.WeightParams.deliveryVehicl = ''
    },
    /**
     * @Description: 初始化消息信息
     * @param {*}
     * @Author: wangwangwang
     */
    initMessageData() {
      const params = {
        clientType: 'pc',
        readStatus: 0,
        page: 1,
        pageSize: 1000,
        receiveUserId: getUserInfo().userId,
      }
      getMessageList(params).then(res => {
        if (res.code === 1001) {
          this.noticeList = res.data.data.filter((item) => {
            const extraField = JSON.parse(item.extraField)
            return extraField.isWeight * 1 === 1
          })
        }
      })
    },
    /**
     * @Description: 查看消息详情
     * @param {*}
     * @Author: wangwangwang
     */
    handleDetails(data) {
      const params = {
        id: data.id,
      }
      setReadType(params).then(res => {
        if (res.code === 1001) {
          this.messagelist = [];
          this.dialogMessageVisible = true;
          this.messagelist.push(JSON.parse(data.content));
          this.initMessageData()
        }
      })
    },
    /**获取站内车辆*/
    gettable2() {
      if (!this.WeightParams.receiveStationId) return
      let data = {
        page: 1,
        pageSize: 9999999,
        receiveStationId: this.WeightParams.receiveStationId,
      }
      if (this.type < 4) {
        query_inner_car(data).then(res => {
          this.table2 = res.data.data
        })
      } else {
        data.dataType = this.type == 4 ? 1 : 2
        queryInstationSpecialMaterial(data).then(res => {
          this.table2 = res.data.data
        })
      }
    },
    /**对应过磅类型数据*/
    gettable3() {
      let _this = this
      if (this.type == 0) {
        query_all_car(this.table3formData).then(res => {
          _this.table3 = res.data.data;
          this.getecharts2();
          if (this.isSecond) {
            this.open('dialog', res.data.data[0]);
          }
        })
      }
      if (this.type == 1) {
        this.table3formData.type = 'type_outer'
        query_weight_car(this.table3formData).then(res => {
          _this.table3 = res.data.data
        })
      }
      if (this.type == 2) {
        this.table3formData.type = 'type_inner'
        query_weight_car(this.table3formData).then(res => {
          _this.table3 = res.data.data
        })
      }
      if (this.type == 3) {
        this.table3formData.carNo = this.table3formData.deliveryVehicl
        query_weight_tare(this.table3formData).then(res => {
          _this.table3 = res.data.data
        })
      }
      if (this.type == 4 || this.type == 5) {
        this.table3formData.carNo = this.table3formData.deliveryVehicl
        this.table3formData.dataType = this.type == 4 ? 1 : 2//1特材入库，2特材返料
        querySpecialMaterialsInner(this.table3formData).then(res => {
          _this.table3 = res.data.data
          this.$nextTick(() => { //在数据加载完，重新渲染表格
            this.$refs['table4-5'].doLayout();
          })
        })
      }
    },
    /**
     * @Description: 输入车牌号查询车辆信息
     * @param {*} async
     * @Author: wangwangwang
     */
    getWeight: _debounce(async function () {
      let _this = this
      if (_this.WeightParams.carNo.length == 7 || _this.WeightParams.carNo.length == 8) {
        if (this.type == 0) {
          get_weight_consignment(_this.WeightParams).then(res => {
            if (!res || res.code !== 1001) {
              _this.weightData = {}
              this.$message.warning('该车牌未查到数据，请确认后重新输入！！！')
              return
            }
            _this.weightData = res.data
            _this.weightData.receiveStationId = _this.WeightParams.receiveStationId
            if (_this.weightData.weightConsignmentId) {
              _this.weightData.id = _this.weightData.weightConsignmentId
            }
            if (_this.weightData.firstWeight) {
              _this.first = false
            } else {
              _this.first = true
            }
            if (res.data.id && res.data.firstTime) {
              this.isSecond = true
            } else {
              this.isSecond = false
            }
          })
        }
        if (this.type == 1) {
          get_tank_car(this.WeightParams).then(res => {
            if (!res) {
              _this.weightData = ''
              this.$message.warning('该车牌未查到数据，请确认后重新输入！！！')
              return
            }
            _this.weightData = res.data
            _this.weightData.type = _this.WeightParams.type
            _this.weightData.receiveStationId = _this.WeightParams.receiveStationId
          })
        }
        if (this.type == 2) {
          get_tank_car(this.WeightParams).then(res => {
            if (!res) {
              _this.weightData = ''
              this.$message.warning('该车牌未查到数据，请确认后重新输入！！！')
              return
            }
            _this.weightData = res.data
            _this.weightData.type = _this.WeightParams.type
            _this.weightData.receiveStationId = _this.WeightParams.receiveStationId
          })
        }
        if (this.type == 3) {
          get_weight_tare(this.WeightParams).then(res => {
            if (!res.data) {
              _this.weightData = ''
              this.$message.warning('该车牌未查到数据，请确认后重新输入！！！')
              return
            }
            _this.weightData = res.data
            _this.weightData.receiveStationId = _this.WeightParams.receiveStationId
            if (_this.weightData.weightConsignmentId) {
              _this.weightData.id = _this.weightData.weightConsignmentId
            }
            if (_this.weightData.firstWeight) {
              _this.first = false
            } else {
              _this.first = true
            }
          })
        }
        if (this.type == 4) {
          getSpecialMaterialsInnerByNo(this.WeightParams).then(res => {
            if (!res.data) {
              _this.weightData = '';
              this.$message.warning('该车牌未查到数据，请确认后重新输入！！！')
              return
            }
            _this.weightData = res.data
            if (_this.weightData.id) {
              _this.first = false
            } else {
              _this.first = true
            }
          })
        }
        if (this.type == 5) {
          getSpecialMaterialsRevertByNo(this.WeightParams).then(res => {
            if (!res.data) {
              _this.weightData = '';
              this.$message.warning('该车牌未查到数据，请确认后重新输入！！！')
              return
            }
            _this.weightData = res.data
            if (_this.weightData.id) {
              _this.first = false
            } else {
              _this.first = true
            }
          })
        }
      } else {
        _this.weightData = {}
      }
    }, 200),
    /**获取仓库和原物料*/
    init() {
      get_materials_list({ stationId: this.WeightParams.receiveStationId }).then(res => {
        this.materialsList = res.data
      })
      get_list({ stationId: this.WeightParams.receiveStationId }).then(res => {
        this.repertoryList = res.data
      })
    },
    /**过磅数据*/
    changeLoadometer() {
      this.websock.close()
      this.initWebSocket();
    },
    initWebSocket() {
      const wsuri = "wss://icps.itence.com:8085/ws_weight/";//这个必须域名连接，否则跨域,域名连接不上就服务器转两次就好了
      this.websock = new WebSocket(wsuri);
      this.websock.onmessage = this.websocketonmessage;
      this.websock.onopen = this.websocketonopen;
      this.websock.onerror = this.websocketonerror;
      this.websock.onclose = this.websocketclose;
    },
    websocketonmessage(e) { //数据接收
      const data = JSON.parse(e.data);
      // console.log(data)
      if (data.code === 1001) {
        this.dataNumber = 0
        this.socketData = data.data;
        this.dataNumber
      }
      if (data.code === 2001) {
        this.dataNumber = 0
      }
    },
    websocketonopen() {
      clearInterval(this.setTime)
      console.log('socket服务正常')
      const params = {
        code: 1002,
        data: this.loadometer
      }
      const data = JSON.stringify(params);
      this.sendData(data);
      let _this = this
      clearInterval(this.time)
      this.time = setInterval(function () {
        const params2 = {
          code: 2001,
          data: 'ping'
        }
        const data2 = JSON.stringify(params2);
        _this.sendData(data2);
      }, 5000)
    },
    sendData(data) {
      console.log(data, '心跳');
      if (!window.WebSocket) { return; }
      if (this.websock.readyState == WebSocket.OPEN) {
        this.websock.send(data);
      } else {
        this.initWebSocket();
      }
    },
    websocketonerror() {//连接建立失败重连
      let _this = this
      if (this.count == 0) {
        this.count++
        clearInterval(_this.setTime)
        _this.setTime = setTimeout(function () {
          _this.initWebSocket();
          _this.$message.error("服务断开,重新连接中。。。")
          this.count = 0
        }, 5000)
      }
    },
    websocketclose(e) {  //关闭
      console.log('断开连接', e);
    },
    /**原物料统计*/
    getrawIdList() {
      if (!this.WeightParams.receiveStationId) return;
      this.getecharts1()
      QueryList({ id: this.WeightParams.receiveStationId }).then(res => {
        this.rawIdList = res.data
      })
    },
    getecharts1() {
      let data = {
        stationId: this.WeightParams.receiveStationId,	//站点id
        ...this.charts1Data
      }
      rawStatistics(data).then(res => {
        let xData = []
        let yData1 = []
        let yData2 = []
        if (res.data) {
          xData = res.data.map(res => (res.supplierName))
          yData1 = res.data.map(res => (res.supplierNumber))
          yData2 = res.data.map(res => (res.actualNumber))
        }

        let myChart1 = echarts.init(document.getElementById('echarts1'));
        let option = {
          title: {
            show: false
          },
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            }
          },
          grid: {
            x: '0', y: '80px'
          },
          legend: {
            type: 'plain',
            left: 0,
            top: 20,
            orient: 'vertical',
            itemGap: 20,
            itemWidth: 35,
            itemHeight: 20
          },
          xAxis: {
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            data: xData
          },
          yAxis: {
            show: false,
          },
          series: [

            {
              name: '计划量',
              type: 'bar',
              data: yData1,
              itemStyle: {
                color: '#2FD9AC',
                padding: 0
              },
            },
            {
              name: '完成量',
              type: 'bar',
              data: yData2,
              barGap: '10%',
              itemStyle: {
                color: '#018A46',
                padding: 0
              },
            },
          ],
        }
        myChart1.setOption(option)
        window.onresize = function () {
          myChart1.resize()
        }

      })
    },
    getecharts2() {
      if (!this.WeightParams.receiveStationId) return
      let data = {
        stationId: this.WeightParams.receiveStationId
      }
      raw_inventory_statistics(data).then(res => {
        let xData = res.data.map(res => (res.warehouseNmae))
        let yData = res.data.map(res => (res.stock))
        let yData1 = res.data.map(res => (res.rawName))
        let yData3 = res.data.map(res => (res.maxStock))
        let myChart2 = echarts.init(document.getElementById('echarts2'));
        let option = {
          title: {
            text: '{a|原物料库存统计}',
            textStyle: {
              rich: {
                a: {
                  fontWeight: 'bold',
                  fontSize: '20',
                },
              }
            }
          },
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            }
          },
          grid: {
            x: '0', y: '80px'
          },
          xAxis: {
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            data: xData
          },
          yAxis: {
            show: false,
          },
          series: [
            {
              z: 2,
              name: '库存量',
              type: 'pictorialBar',
              symbol: 'rect',
              symbolSize: ['90%', '100%'],
              data: yData,
              color: '#018A46',
            },
            {
              z: 1,
              name: '满仓量',
              type: 'bar',
              symbolPosition: 'start',
              // barWidth: 28,
              data: yData3,
              barCategoryGap: '30%',
              itemStyle: {
                color: 'rgba(0,0,0,0.1)',
                borderWidth: 1,
                borderColor: 'rgba(0,0,0,0.3)',
                padding: 0
              },
              label: {
                show: true,
                position: ['50%', '-20'],
                color: '#000',
                fontSize: 12,
                fontStyle: 'bold',
                align: 'center',
                formatter: function (params) {
                  return yData1[params.dataIndex];
                },
              },
            },
          ],
        }
        myChart2.setOption(option)
        window.onresize = function () {
          myChart2.resize()
        }

      })
    },
    /**打开弹窗*/
    open(key, low) {
      this.low = low;
      console.log(JSON.parse(JSON.stringify(this.low)))
      this[key] = true;
    },
    /**打印*/
    print() {
      let print = document.getElementsByClassName("print")[0].innerHTML  //获取目标区域
      const iframeDom = document.createElement('iframe')
      const attrObj = {
        height: 0,
        width: 0,
        border: 0,
        id: 'iframe'
      }
      const styleObj = {
        position: 'fixed',
        'z-index': '-999',
      }
      Object.entries(attrObj).forEach(([key, value]) => iframeDom.setAttribute(key, value))
      Object.entries(styleObj).forEach(([key, value]) => { iframeDom.style[key] = value })
      document.body.appendChild(iframeDom);
      const iframeDocs = iframeDom.contentWindow.document
      iframeDocs.write(print)
      window.setTimeout(function () {
        iframeDom.contentWindow.print()
        document.body.removeChild(iframeDom)
      }, 200)
    },
    rawSupplierSendMessageFun(row) {
      rawSupplierSendMessage({ code: row.code, id: row.id }).then((res) => {
        if (res.code == 1001) {
          this.$message({
            message: '发送成功',
            type: 'success'
          });
          this.dialog = false
        }
      })
    },
  },
};
</script>
<style lang="scss" scope>
.text1 {
  border: 1px solid #c3c0bb;
  border-radius: 4px;
  padding: 0 10px;
  display: flex;
  align-items: center;
}
.col {
  display: flex;
  align-items: center;
}
.pages {
  min-width: 1400px;
  background: #f2f5f3;
  padding: 24px;
  min-height: 100vh;
  .top {
    width: 100%;
    height: 339px;
    border-radius: 4px;
    background: #ffffff;
    padding: 24px;
  }
}
.search {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .search_left {
    display: flex;
    .save_button {
      width: 84px;
      height: 36px;
      margin-left: 24px;
      background: #00a754;
      color: #ffffff;
    }
    .save_button:hover {
      opacity: 0.5;
    }
    .save_button:active {
      opacity: 1;
      background: #008c47;
    }
  }
  .search_right {
    position: relative;
    .el-badge {
      width: 115px;
      height: 36px;
      background: #ffffff;
      border: 1px solid #cccccc;
      border-radius: 4px;
      cursor: pointer;
      .text {
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 14px;
        color: #000000;
      }
    }
    .el-badge:hover {
      background: #edfbf4;
      border: 1px solid #cceddd;
      .text {
        color: #00a754;
      }
    }
    .el-badge:active {
      background: #edfbf4;
      border: 1px solid #008c47;
      .text {
        color: #008c47;
      }
    }
    .notice-container {
      position: absolute;
      top: 50px;
      right: 0;
      border-radius: 10px;
      border: 1px solid #c3c0bb;
      background: #fff;
      padding: 10px 20px;
      z-index: 1000;
    }
  }
}
.bottom {
  .title {
    width: 64px;
    padding: 28px 0 16px 0;
    font-size: 16px;
    font-weight: bold;
    line-height: 22px;
    color: #000000;
  }
  .top_nav {
    display: flex;
    > div {
      width: 110px;
      height: 48px;
      margin-right: 6px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .active {
      background: #f5f7fa;
      border: 1px solid #e1e5ed;
      border-top: 2px solid #00a754;
      font-size: 16px;
      font-weight: bold;
      color: #00a754;
    }
    .div {
      background: #00a754;
      color: #ffffff;
    }
    .div:hover {
      opacity: 0.5;
    }
    .div:active {
      opacity: 1;
      background: #008c47;
    }
  }
  .top_table {
    height: 140px;
    border: 1px solid #e1e5ed;
  }
}
.center {
  height: 564px;
  padding-top: 24px;
  display: flex;
  .hr {
    width: 24px;
    height: 100%;
  }
  .left,
  .right {
    .title {
      width: 64px;
      padding: 0 0 16px 0;
      font-size: 16px;
      font-weight: bold;
      line-height: 22px;
      color: #000000;
    }
    flex: 1;
    overflow: auto;
    padding: 24px;
    background: #ffffff;
    border-radius: 4px;
  }
  .right {
    .input {
      padding-right: 24px;
      padding-bottom: 16px;
      display: flex;
      .text {
        width: 65px;
        display: flex;
        padding-right: 8px;
        align-items: center;
        font-size: 14px;
        color: #000000;
      }
      > .el-input,
      > .el-select {
        width: calc(100% - 65px);
      }
    }
    .save_button {
      width: 84px;
      height: 36px;
      background: #00a754;
      color: #ffffff;
    }
    .save_button:hover {
      opacity: 0.5;
    }
    .save_button:active {
      opacity: 1;
      background: #008c47;
    }
    .table_link {
      margin: 0 10px;
      color: #00a754;
      cursor: pointer;
    }

    .table_link:hover {
      opacity: 0.8;
    }
  }
}
.echarts {
  width: 100%;
  height: 540px;
  padding-top: 24px;
  display: flex;
  .hr {
    width: 24px;
    height: 100%;
  }
  .left,
  .right {
    flex: 1;
    padding: 24px;
    background: #ffffff;
    border-radius: 4px;
  }
  .left_nav {
    display: flex;
    // justify-content: space-between;
    align-items: center;
    .save_button {
      width: 84px;
      height: 36px;
      background: #00a754;
      color: #ffffff;
    }
    .save_button:hover {
      opacity: 0.5;
    }
    .save_button:active {
      opacity: 1;
      background: #008c47;
    }
  }
}
#echarts1 {
  height: 100%;
  width: 100%;
}
#echarts2 {
  height: 100%;
  width: 100%;
}
.el-table .success-row {
  background: #f0f9eb !important;
}
</style>
